<template>
	<view class="body">
		<form @submit="formSubmit">
					<view class="face-wapper">
						<image src="../../static/icons/default-face.png" class="face"></image>
					</view>
					
					<view class="info-wapper">
						<label class="words-lbl">账号</label>
						<input name="username" type="text" value="" class="input" placeholder="请输入用户名" placeholder-class="graywords"/>
					</view>
					
					<view class="info-wapper" style="margin-top: 40upx;">
						<label class="words-lbl">密码</label>
						<input name="password" type="text" value="" password="true" class="input" placeholder="请输入密码" placeholder-class="graywords"/>
					</view>
					
					<button type="primary" form-type="submit" style="margin-top: 60upx;width: 90%;">注册/登录</button>
		</form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			async formSubmit(e){
				var username = e.detail.value.username;
				var password = e.detail.value.password;
				const res = await this.$myRequest({
					url: '/makerwit/wms/login',
					data: {
					"account": username,
					"password": password
					},
					method: 'POST'
				})
				console.log(res.data.data);
				var userInfo = res.data.data;
				//保存用户信息到全局的缓存中
				uni.setStorageSync("globalUser",userInfo);
				//切换页面跳转，使用tab切换的api
				uni.switchTab({
					url: "../my/my"
				})
			},
		}
	}
</script>

<style>
@import url("registLogin.css");
</style>
